<template>
  <div>
    <el-button
      v-for="(btn, num) in buttons"
      :key="num"
      :type="btn.handleGetType ? btn.handleGetType(initData) : btn.type"
      :size="btn.size"
      :plain="btn.plain"
      @click="btn.handelClick(initData, index)"
      v-show="btn.handleGetVisible ? btn.handleGetVisible(initData) : true"
    >
      {{ btn.handleGetName ? btn.handleGetName(initData) : btn.label }}
    </el-button>
    <!-- {{logdata(initData)}} -->
  </div>
</template>
<script>
export default {
  name: "z-button-list",
  data () {
    return {}
  },
  props: {
    /* buttons
      {
        label: "停用",
        handleGetName: (row) => {
          return row.status === 1 ? "停用" : "启用";
        },
        type: "danger",
        handleGetType: (row) => {
          return row.status === 1 ? "danger" : "success";
        },
        plain: true,
        size: "mini",
        handelClick: (row) => {
          this.setEvent(row);
        },
        handleGetVisible:(row)=>{
          return row.status === 1;
        }
      }
    */
    buttons: Array,
    initData: Object,
    index: Number
  },
  watch: {
    initData (val) {
      console.log(" button initData", val)
    }
  },
  methods: {
    // logdata(val) {
    //   console.log("logdata", val);
    // }
  },
  mounted () {
    // console.log("buttonList", this.initData);
  }
};
</script>
